'use strict';

var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');
Object.defineProperty(exports, '__esModule', {
  value: true,
});
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require('@babel/runtime/helpers/objectSpread2'));
var _objectWithoutProperties2 = _interopRequireDefault(
  require('@babel/runtime/helpers/objectWithoutProperties'),
);
var _react = _interopRequireDefault(require('react'));
var _antd = require('antd');
var _createField = _interopRequireDefault(require('../../createField'));
var _FieldContext = require('../../contexts/FieldContext');
var _excluded = ['children', 'mode'];
/**
 * 自动完成，扩展输入框、文本框、搜索框三种展示模式
 * @param props
 * @returns
 */
var AutoComplete = function AutoComplete(_ref) {
  var children = _ref.children,
    _ref$mode = _ref.mode,
    mode = _ref$mode === void 0 ? 'input' : _ref$mode,
    props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var _useFieldContext = (0, _FieldContext.useFieldContext)(),
    label = _useFieldContext.label;
  var node = null;
  var placeholder = '';
  switch (mode) {
    case 'textarea':
      node = /*#__PURE__*/ _react.default.createElement(_antd.Input.TextArea, {
        placeholder: placeholder,
        className: 'custom',
        style: {
          height: 50,
        },
      });
      placeholder = '\u8BF7\u8F93\u5165'.concat(
        label || '',
        '\uFF0C\u6216\u9009\u62E9\u5339\u914D\u9879',
      );
      break;
    case 'search':
      node = /*#__PURE__*/ _react.default.createElement(_antd.Input.Search, {
        placeholder: placeholder,
        enterButton: true,
      });
      placeholder = '\u8BF7\u641C\u7D22';
      break;
    default:
      placeholder = '\u8BF7\u8F93\u5165'.concat(
        label || '',
        '\uFF0C\u6216\u9009\u62E9\u5339\u914D\u9879',
      );
      break;
  }
  return /*#__PURE__*/ _react.default.createElement(
    _antd.AutoComplete,
    (0, _objectSpread2.default)(
      {
        placeholder: placeholder,
      },
      props,
    ),
    node,
    children,
  );
};
var FinalAutoComplete = (0, _createField.default)(AutoComplete);
FinalAutoComplete.Option = _antd.AutoComplete.Option;
var _default = FinalAutoComplete;
exports.default = _default;
